<?php
/**
 * Project: AIGC
 * Author: moufer <moufer@163.com>
 * Date: 2024/8/31 21:34
 */

namespace module\user\middleware;

use Closure;
use module\user\library\Auth;
use mof\ApiResponse;
use mof\exception\AuthTokenException;
use mof\Request;
use think\Response;

class NeedLoginMiddleware
{
    /**
     * 处理请求
     *
     * @param Request $request
     * @param Closure $next
     * @return Response
     */
    public function handle(Request $request, Closure $next): Response
    {
        if (!$request->user) {
            return ApiResponse::needLogin('请先登录');
        }
        return $next($request);
    }
}